﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using Libs.Configs;
using Libs.Db;

namespace Libs.Content
{
    public class Goods
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Price { get; set; }        
        public string Rate { get; set; }
        public DateTime CreatedDate { get; set; }
        public Goods()
        {

        }

        ~Goods()
        {

        }

        public virtual void Dispose()
        {

        }
        /// <summary>
        /// Thêm mới tin bài
        /// </summary>
        public void Add()
        {
            DbHelper db = new DbHelper(Config.NewsConnectionStrings);
            SqlParameter[] pars = new SqlParameter[3];
            pars[0] = new SqlParameter("@Name", Name);
            pars[1] = new SqlParameter("@Price", Price);            
            pars[2] = new SqlParameter("@Rate", Rate);
            db.ExecuteNonQuerySP("sp_Goods_Insert", pars);
        }
        public List<Goods> GetList()
        {
            DbHelper db = new DbHelper(Config.NewsConnectionStrings);
            return db.GetListSP<Goods>("sp_Goods_GetList");
        }

    }
}
